Home:ALL Converter>Connecting to SQL Server with current user

Connecting to SQL Server with current user

Ask Time:2020-03-09T18:53:36         Author:Henry

Json Formatter

I need to build an service that connects to a SQL Server. My idea for authentication was to use the executing user, so I don't have to work manually with changing passwords. To connect to the SQL Server I use the System.Data.SQLClient, until now I set up a SQLConnectionStringBuilder and hardcode the credentials.

I tried to use the given NetworkCredentials from the user but could not find a way to use it for the SQL Connection.

Is there any way this could work? If not, how can I securely save the user credentials (e.g. in a file?) to read when running? The application shall run as a headless service every night so I can't use userinput while running.

Thanks in advance

Author:Henry,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60599051/connecting-to-sql-server-with-current-user
yy